package com.mytrip.webapp.action;

import com.mytrip.base.action.StrutsActionAdapter;
import com.mytrip.model.News;
import com.mytrip.service.NewsManager;
import com.mytrip.util.PageInfo;

public class FrontNewsAction extends StrutsActionAdapter{

	private static final long serialVersionUID = 3726608503814030778L;

	private NewsManager newsManager;

	private PageInfo<News> page = new PageInfo<News>(20);
	
	private News news;

	public String list() throws Exception{
		page.setUrl(getRequest().getContextPath() + "/front/news!list.action");
		page.setAllSize(newsManager.queryNewsCnt());
		page.setDataList(newsManager.queryNews(page.getFrom(), page.getPageSize()));
		return "list";
	}

	public String detail() throws Exception{
		Integer id = Integer.valueOf(getRequest().getParameter("id"));
		news = newsManager.queryNewsById(id);
		return "detail";
	}

	public void setNewsManager(NewsManager newsManager){
		this.newsManager = newsManager;
	}

	public PageInfo<News> getPage(){
		return page;
	}

	public void setPage(PageInfo<News> page){
		this.page = page;
	}

	public News getNews(){
		return news;
	}

	public void setNews(News news){
		this.news = news;
	}
}
